<template>
  <div class="shop-info" v-if="Object.keys(shop).length !== 0">
    <div class="shop-top">
      <img :src="shop.logo" alt="">
      <span class="shop-name">{{shop.name}}</span>
    </div>
    <div class="shop-middle">
      <div class="shop-middle-item shop-middle-left">
        <div class="info-sells">
          <div class="sells-count">
            {{shop.sells|sellCountFilter}}
          </div>
          <div class="sells-text">
            总销量
          </div>
        </div>
        <div class="info-goods">
          <div class="goods-count">
            {{shop.goodsCount}}
          </div>
          <div class="goods-text">
            全部宝贝
          </div>
        </div>
      </div>
      <div class="shop-middle-item shop-middle-right">
        <table>
          <tr v-for="(item,index) in shop.score" :key="index">
            <td>{{item.name}}</td>
            <td class="score" :class="{'score-better':item.isBetter}">{{item.score}}</td>
            <td class="better" :class="{'better-more':item.isBetter}"><span>{{item.isBetter ? '高' : '低'}}</span></td>
          </tr>
        </table>
      </div>
      <div class="border"></div>
    </div>
    <div class="shop-bottom">
      <div class="enter-shop">进店逛逛</div>
    </div>
  </div>
</template>

<script>
export default {
  name:"DetailShopInfo",
  props:{
    shop:{
      type:Object,
      default(){
        return {}
      }
    }
  },
  filters:{
    sellCountFilter(value){
      if(value < 10000) return value
      else return (value/10000).toFixed(1)+'万'
    }
  }
}
</script>

<style scoped>
  .shop-info {
    padding: 25px 8px;
    border-bottom: 5px solid #f2f5f8;
    font-size: 16px;
  }

  .shop-top {
    line-height: 70px;
    display: flex;
    align-content: center;
  }

  .shop-top img {
    width: 70px;
    height: 70px;
    padding: 1px;
    border-radius: 50%;
    border:2px solid rgba(0,0,0,.1);
  }
  .shop-top .shop-name {
    margin-left: 10px;
    font-size: 18px;
  }
  .shop-middle {
    width: 100%;
    margin-top: 15px;
    display: flex;
    justify-content:center;
    align-content: center;
    position: relative;
  }

  .shop-middle-left {
    width: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .info-sells,.info-goods {
    color: #333;
    text-align: center;
    width: 50%;
  }
  .sells-count,.goods-count {
    font-size: 24px;
  }
  .sells-text, .goods-text{
    padding: 10px 0;
  }

  .shop-middle-right {
    width: 50%;
  }

  table {
    width: 80%;
    margin-left: 50%;
    transform: translateX(-50%);
  }

  table tr td:nth-child(1){
    text-align: center;
  }

  table tr td {
    padding:7px 5px 7px 0;
    color: #333;
  }

  .shop-middle-right .score {
    color: #5ea732;
  }

  .shop-middle-right .better span{
    color: #fff;
    background-color: #5ea732;
  }

  .shop-middle-right .score-better {
    color: #f13e3a;
  }

  .shop-middle-right .better-more span{
     background-color: #f13e3a;
  }

  .border {
    position: absolute;
    top: 22%;
    left: 50%;
    width: 0;
    height: 52px;
    border-right: 1px solid rgba(0,0,0,.1);
  }

  .shop-bottom {
    width: 100%;
    margin-top: 15px;
  }

  .enter-shop {
    width: 35%;
    padding: 7px 15px;
    margin-left: 50%;
    transform: translateX(-50%);
    text-align: center;
    background-color: #f2f5f8;
    border-radius: 13px;
  }

</style>